How To Optimize A Fitted Curve In Matlab